<?php

namespace app\admin\model;

use app\common\model\MoneyLog;
use think\Model;

class Dashboard extends Model
{
    // 表名
    protected $name = 'article';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    protected $pk = 'id';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    //自定义初始化
    protected function initialize()
    {
        //需要调用`Model`的`initialize`方法
        parent::initialize();
    }

    // 追加属性
    protected $append = [

    ];
    public function get1(){

    }

    public function play_priceorder(){

        //商家订单model
        $model_shoporder=new Litestoreshoporder();
        //查询总订单
        $order['shopordercount']=$model_shoporder->count();

        //当天订单支付总金额
        $todayplay_priceordersum=$model_shoporder
            ->whereTime('createtime', 'today')
            ->sum('play_price');

        //当天订单余额支付总金额
        $todayremainderordersum=$model_shoporder
            ->whereTime('createtime', 'today')
            ->sum('remainder');
        //当天订单支付总金额+当天订单余额支付总金额
        $todayordersum=$todayplay_priceordersum+$todayremainderordersum;
        $order['todayordersum']=round($todayordersum,2);


        //当年订单支付总金额
        $yearplay_priceordersum=$model_shoporder
            ->whereTime('createtime', 'year')
            ->sum('play_price');

        //当年订单余额支付总金额
        $yearremainderordersum=$model_shoporder
            ->whereTime('createtime', 'year')
            ->sum('remainder');

        //当年订单支付总金额+当年订单余额支付总金额
        $yearordersum=$yearplay_priceordersum+$yearremainderordersum;
        $order['yearordersum']=round($yearordersum,2);

        $model_user=new User();
        //当天贡献值
        $order['todaycontributionsum']=$model_user
            ->whereTime('createtime', 'today')
            ->sum('score');

        //当年贡献值
        $order['yearcontributionsum']=$model_user
            ->whereTime('createtime', 'year')
            ->sum('score');

        //用户资金流水model
        $model_money=new Usermoney();

        //当年分红
        $order['yearbonus']=$model_money
            ->whereTime('createtime', 'year')
            ->where(['money_type'=>4])
            ->sum('money');

        //当天分红
        $order['dbonus']=$model_money
            ->whereTime('createtime', 'today')
            ->where(['money_type'=>4])
            ->sum('money');

        //提现model
        $model_depost=new Deposit();
        //当年提现通过
        $order['yeardepost']=$model_depost
            ->whereTime('createtime', 'year')
            ->where(['status'=>2])
            ->sum('money');

        //当年提现审核中
        $order['yeardepostaudit']=$model_depost
            ->whereTime('createtime', 'year')
            ->where(['status'=>1])
            ->sum('money');

        //当天提现通过
        $order['ddepost']=$model_depost
            ->whereTime('createtime', 'today')
            ->where(['status'=>1])
            ->sum('money');

        //当年提现审核中
        $order['ddepostaudit']=$model_depost
            ->whereTime('createtime', 'today')
            ->where(['status'=>1])
            ->sum('money');

        return $order;
    }
    

    







}
